﻿<%@ Page Title="" Language="C#" MasterPageFile="~/masterpagecuatui.Master" AutoEventWireup="true" CodeBehind="Lesson.aspx.cs" Inherits="SQT.tracnghiem.Lesson" %>

<%@ Import Namespace="DataAccess" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title>Học tiếng nhật - Tiếng nhật thật dễ</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="page-main-content w3-light-grey w3-row w3-padding">
        <div class="w3-twothird w3-padding">
            <%var get_lesson = new TblLessonController().FetchAll().Where(x => x.LessonActive == true && x.LessonTurn == true);
            %>

            <div id="trinhdo1" class="cer-content w3-white w3-row w3-padding">
                <%foreach (TblLesson lesson in get_lesson)
                  {
                      string title = "";
                      string name = "";
                      if (lesson.LessonTitle.IndexOf(":") != -1)
                      {
                          title = lesson.LessonTitle.Split(':')[1];
                          name = lesson.LessonTitle.Split(':')[0];
                      }
                      else
                      {
                          name = lesson.LessonTitle;
                      }

                      if (checkRoleUser(lesson.LessonRole))
                      {%>
                <a href="/giao-an/<%=convertToUrl(lesson.LessonTitle)%>-<%=lesson.LessonId%>">
                    <div class="cer-test-item hvr-float-shadow w3-quarter" data-toggle="tooltip" data-placement="bottom" title="<%=title%>">
                        <div class="cer-test-picture w3-row">
                            <img src="../Content/img/logo_sqt.jpg" />
                        </div>
                        <div class="cer-test-tittle w3-center w3-teal">
                            <span><%=name%></span>
                        </div>
                    </div>
                </a>
                <%}
                      else
                      {
                %>
                <div class="cer-test-item hvr-float-shadow w3-quarter" data-toggle="tooltip" data-placement="bottom" title="<%=title%>">
                    <div class="cer-test-picture w3-row w3-display-container">
                        <img src="../Content/img/logo_sqt.jpg" />
                        <div class="cer-test-lock w3-display-bottommiddle"><i class="w3-xxlarge w3-text-white fa fa-lock"></i></div>
                    </div>
                    <div class="cer-test-tittle w3-center w3-teal">
                        <span><%=name%></span>
                    </div>
                </div>
                <%
                      }
                  } %>
            </div>
        </div>
        <div class="w3-third w3-padding">
            <header class="w3-padding w3-center w3-teal w3-large">HỎI ĐÁP<a href="javascript:;" class="usual-ques-btn w3-right w3-border w3-teal w3-hover-brown" title="Câu hỏi thường gặp">?</a></header>
            <div class="faq-area w3-white">
                <ul class="faq-list" id="cmt_area">
                    <%var get_cmt = from p in new TblLessonCommentController().FetchAll() orderby p.CmtDate descending select p;
                      foreach (TblLessonComment cmt in get_cmt)
                      {
                          var get_user = new TblUserController().FetchAll().Where(x => x.UserId == cmt.UserId).Single();
                          var get_reply = new TblLessonCommentReplyController().FetchAll().Where(x => x.CmtId == cmt.Id);
                    %>
                    <li id="cmt_<%=cmt.Id %>" class="w3-row">
                        <div class="faq-avatar w3-col">
                            <img src="../Content/avatar/<%=get_user.Avatar %>" class="w3-circle" />
                        </div>
                        <div class="faq-content w3-col">
                            <%if(get_user.UserLevel !=5){ %>
                            <span class="faq-user"><%=get_user.FullName %> :</span>&nbsp;<span class="cmt_Content"><%=cmt.CmtContent %></span><%}else{ %>
                            <span class="faq-user w3-text-red"><%=get_user.FullName %> :</span>&nbsp;<span class="cmt_Content"><%=cmt.CmtContent %></span>
                            <%} %><br />

                            <div class="w3-small w3-padding-bottom"><%if (Session["user_id"] != null)
                                                                      {%><a onclick="answer_btn(event)" class="faq-answer-btn faq-text-btn">Trả lời</a><%if (Session["level"].ToString() == "5")                                                                                                                   { %><a onclick="pin_btn(<%=cmt.Id %>)" <%if(cmt.CmtPin==true){ %>style="display:none"<%} %> class="faq-ghim-btn faq-text-btn">Ghim</a><a onclick="unpin_btn(<%=cmt.Id %>)" <%if(cmt.CmtPin==true){ %>style="display:inline-block"<%} %> class="faq-unghim-btn faq-text-btn">Bỏ ghim</a><%}
                                                                      }else{ %><a onclick="authentication()" class="faq-answer-btn faq-text-btn">Trả lời</a><%} %><span class="faq-time w3-text-grey"><%if(cmt.CmtEdit==false){ %>Đã đăng - <%}else{ %>Đã chỉnh sửa - <%} %><%=datetimeToString(cmt.CmtDate.ToString()) %></span></div>
                            <div class="faq-answer-content">
                                <%if (get_reply.ToList().Count != 0)
                                  { %>
                                <div class="nut-hien w3-small w3-padding-bottom"><a onclick="show_answer(event)" class="faq-show-older-answer-btn faq-text-btn">Xem <%=get_reply.ToList().Count %> câu trả lời trước&nbsp;<i class="fa fa-angle-down"></i></a></div>
                                <div class="nut-an w3-small w3-padding-bottom"><a onclick="hide_answer(event)" class="faq-hide-older-answer-btn faq-text-btn">Ẩn <%=get_reply.ToList().Count %> câu trả lời trước&nbsp;<i class="fa fa-angle-up"></i></a></div>
                                <%} %>
                                <ul class="faq-answer-list faq-teacher-reply">
                                    <%if (findReplyTeacher(cmt.Id) != null)
                                      {
                                          var get_teacher_reply = new TblLessonCommentReplyController().FetchAll().Where(x => x.Id == findReplyTeacher(cmt.Id)).Single();
                                          var get_teacher = new TblUserController().FetchAll().Where(x => x.UserId == get_teacher_reply.UserId).Single();
                                    %>
                                    <li class="w3-row reply_<%=get_teacher_reply.Id %>">
                                        <div class="faq-answer-avatar w3-col">
                                            <img src="../Content/avatar/<%=get_teacher.Avatar %>" class="w3-circle" />
                                        </div>
                                        <div class="faq-content w3-col l10">
                                            <div class="faq-answer-content-edit">
                                                <input type="text" value="<%=get_teacher_reply.CmtContent %>" placeholder="Viết trả lời..." autofocus="autofocus" />
                                            </div>
                                            <div class="faq-answer-content"><span class="faq-user w3-text-red"><%=get_teacher.FullName %> :</span>&nbsp;<span><%=get_teacher_reply.CmtContent %></span></div>
                                            <div class="w3-small">
                                            <%if (Session["user_id"] != null)
                                              { %><%if (int.Parse(Session["user_id"].ToString()) == get_teacher_reply.UserId)
                                                    { %><a class="faq-edit-answer-btn faq-text-btn">Chỉnh sửa</a><a class="faq-cancel-edit-answer-btn faq-text-btn">Hủy</a><a onclick="del_reply(<%=get_teacher_reply.Id %>)" class="faq-delete-btn faq-text-btn">Xóa</a><%}
                                              } %><span class="faq-time w3-text-grey"><%=datetimeToString(get_teacher_reply.CmtDate.ToString()) %></span>
                                            </div>
                                        </div>
                                    </li>
                                    <%} %>
                                </ul>
                                <ul class="faq-answer-list faq-older-answer">
                                    <%foreach(TblLessonCommentReply reply in get_reply){
                                          var get_user_reply = new TblUserController().FetchAll().Where(x => x.UserId == reply.UserId).Single();
                                          %>
                                    <li class="w3-row reply_<%=reply.Id %>">
                                        <div class="faq-answer-avatar w3-col">
                                            <img src="../Content/avatar/<%=get_user_reply.Avatar %>" class="w3-circle" />
                                        </div>
                                        <div class="faq-content w3-col l10">
                                            <div class="faq-answer-content-edit">
                                                <input type="text" id="txt_answer_edit_<%=reply.Id %>" onblur="clear_edit();clear_input()" onclick="edit_answer(<%=reply.Id%>);get_input(<%=cmt.Id%>)" value="<%=reply.CmtContent %>" placeholder="Viết trả lời..." autofocus="autofocus" />
                                            </div>
                                            <div class="faq-answer-content"><%if(get_user_reply.UserLevel!=5){ %><span class="faq-user"><%=get_user_reply.FullName %> :</span><%}else{ %><span class="faq-user w3-text-red"><%=get_user_reply.FullName %> :</span><%} %>&nbsp;<span><%=reply.CmtContent %></span></div>
                                            <div class="w3-small"><%if(Session["user_id"]!=null){ %><%if(Session["user_id"].ToString()==reply.UserId.ToString()) {%><a class="faq-edit-answer-btn faq-text-btn">Chỉnh sửa</a><a class="faq-cancel-edit-answer-btn faq-text-btn">Hủy</a><a onclick="del_reply(<%=reply.Id %>)" class="faq-delete-btn faq-text-btn">Xóa</a><%} }%><span class="faq-time w3-text-grey"><%=datetimeToString(reply.CmtDate.ToString()) %></span></div>
                                        </div>
                                    </li>
                                    <%} %>
                                </ul>
                                <%if(Session["user_id"]!=null){
                                      var user = new TblUserController().FetchAll().Where(x => x.UserId == int.Parse(Session["user_id"].ToString())).Single();
                                      %>
                                <ul class="faq-answer-list">
                                    <li class="faq-answer-row w3-row">
                                        <div class="faq-answer-avatar w3-col">
                                            <img src="../Content/avatar/<%=user.Avatar %>" class="w3-circle" />
                                        </div>
                                        <div class="faq-answer-input w3-col l10">
                                            <input type="text" class="txt_answer" onblur="clear_input()" onclick="get_input(<%=cmt.Id%>)" placeholder="Viết trả lời..." />
                                        </div>
                                    </li>
                                </ul>
                                <%} %>
                            </div>
                        </div>
                        <div class="faq-action w3-center">
                            <%if(cmt.CmtPin==false){ %>
                            <i class="faq-ghim-sign faq-ghim-sign-hide fa fa-bookmark w3-text-deep-orange"></i>
                            <%}else{ %>
                            <i class="faq-ghim-sign faq-ghim-sign-show fa fa-bookmark w3-text-deep-orange"></i>
                            <%} %>
                            <%if (Session["user_id"] != null)
                              { %>
                            <%if (Session["level"].ToString() == "5" || Session["user_id"].ToString() == cmt.UserId.ToString())
                              { %>
                            <div class="dropdown">
                                <i data-toggle="dropdown" class="faq-option-btn fa fa-angle-down dropdown-toggle" title="Tùy chọn"></i>
                                <div class="dropdown-menu dropdown-menu-right">
                                    <ul class="faq-option-list">
                                        <li onclick="edit_cmt(<%=cmt.Id %>)"><a href="javascript:;"><i class="fa fa-edit"></i>&nbsp;Chỉnh sửa</a></li>
                                        <li onclick="del_cmt(<%=cmt.Id %>)"><a href="javascript:;"><i class="fa fa-trash"></i>&nbsp;Xóa</a></li>
                                    </ul>
                                </div>
                            </div>
                            <%}
                              } %>
                        </div>
                    </li>
                    <%} %>
                </ul>
                <%if(Session["user_id"]!=null){
                      var user = new TblUserController().FetchAll().Where(x => x.UserId == int.Parse(Session["user_id"].ToString())).Single();
                      %>
                <div class="faq-question-input w3-row w3-teal">
                    <div class="faq-avatar w3-col">
                        <img src="../Content/avatar/<%=user.Avatar %>" class="w3-circle" />
                    </div>
                    <div class="faq-content faq-question-action w3-col">
                        <input type="text" id="txt_reply" onblur="clear_input()" onclick="get_input('0')" placeholder="Viết câu hỏi..." class="w3-text-dark-grey" /><i class="fa fa-send w3-text-teal w3-large" style="cursor: pointer"></i>
                    </div>
                    <div class="faq-action w3-rest w3-center">
                        <i class="faq-icon-btn fa fa-smile-o" title="Thêm Icon"></i>
                    </div>
                </div>
                <%} %>
            </div>
        </div>
    </div>
    <div id="usual-ques-modal" class="w3-modal">
        <div class="usual-ques-modal w3-modal-content w3-card-8 w3-animate-top w3-white">
            <header class="w3-padding w3-center w3-teal w3-xlarge">CÂU HỎI THƯỜNG GẶP<a class="w3-right w3-text-white" href="javascript:;" onclick="$('#usual-ques-modal').fadeOut()"><i class="fa fa-times"></i></a></header>
            <ul class="usual-ques-list w3-ul">
                <%var get_faq = new TblFAQController().FetchAll().Where(x => x.Active == true);
                  foreach (TblFAQ faq in get_faq)
                  {
                %>
                <li>
                    <p class="usual-ques-item w3-text-teal w3-large"><%=faq.Question %></p>
                    <p class="usual-ques-answer w3-text-brown"><%=faq.Answer %></p>
                </li>
                <%} %>
            </ul>
        </div>
    </div>
    <div id="del_reply" class="w3-modal">
        <div class="usual-ques-modal w3-modal-content w3-card-8 w3-animate-top w3-white">
            <header class="w3-padding w3-center w3-teal w3-xlarge">Xóa bình luận<a class="w3-right w3-text-white" href="javascript:;" onclick="$('#del_reply').fadeOut()"><i class="fa fa-times"></i></a></header>
            <div class="w3-padding w3-large">
                Bạn có chắc chắn muốn xóa bình luận này không?
            </div>
            <div class="w3-right-align w3-padding"><a onclick="$('#del_reply').fadeOut()" class="w3-btn w3-padding w3-grey w3-margin-right">Không</a><a onclick="btn_del_reply();" class="w3-btn w3-padding w3-teal w3-margin-right">Có</a></div>
        </div>
    </div>
    <div id="del_cmt" class="w3-modal">
        <div class="usual-ques-modal w3-modal-content w3-card-8 w3-animate-top w3-white">
            <header class="w3-padding w3-center w3-teal w3-xlarge">Xóa bình luận<a class="w3-right w3-text-white" href="javascript:;" onclick="$('#del_cmt').fadeOut()"><i class="fa fa-times"></i></a></header>
            <div class="w3-padding w3-large">
                Bạn có chắc chắn muốn xóa bình luận này không?
            </div>
            <div class="w3-right-align w3-padding"><a onclick="$('#del_cmt').fadeOut()" class="w3-btn w3-padding w3-grey w3-margin-right">Không</a><a onclick="btn_del_cmt();" class="w3-btn w3-padding w3-teal w3-margin-right">Có</a></div>
        </div>
    </div>
    <script src="../Scripts/lessonjava.js"></script>
</asp:Content>
